{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "3d6844a3-fa9f-43cb-b938-a87fa1753b23",
   "metadata": {},
   "outputs": [],
   "source": [
    "import json\n",
    "from utils import datasets, generate_config, display_config"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "986cf9c8-a062-4e17-9ce6-a813d71faae5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5 6\n"
     ]
    }
   ],
   "source": [
    "data_train, data_test = datasets(path = './data_examples/')\n",
    "print(len(data_train), len(data_test))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "21763789-8233-4f14-be94-d4df622e655c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "I have a 1,3-dipolar cycloaddition reaction wherein my starting material can be converted to product through an intermediate. The first step in the mechanism is a intramolecular rearrangement under acidic conditions (Lewis acid or acid – as the reagent) where the starting material is converted into an intermediate species that undergoes a facile tautomerization to the product through a proton transfer event, this would be the second reaction. This step is irreversible due to the fact the tautomer is aromatic. Assume reactions are happening at elevated temperatures above 25.\n"
     ]
    }
   ],
   "source": [
    "test_idx = 0\n",
    "description = data_test[test_idx]['Input']\n",
    "print(description)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "f1d14441-b06b-44d6-af97-002a4e6020d7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Generated config:\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "9ddd7c42dad5402dba170e0b6d5dc496",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Textarea(value='{\\n    \"rxn1\": {\\n        \"reactants\": {\\n            \"starting_material\": 1,\\n            \"re…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "0fee88013e674160a031fc2cd0163ed9",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Button(description='Save Config', style=ButtonStyle())"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "config_path = 'config.json'\n",
    "model_config = generate_config(description, data_train, data_test)\n",
    "print(\"Generated config:\")\n",
    "display_config(model_config, config_path)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "64cdd7f5-915e-4f24-9962-43785ae81e83",
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "print(f\"\"\"\n",
    "Generated config:\n",
    "{model_config}\n",
    "Correct config:\n",
    "{data_test[test_idx]['Output']}\n",
    "\"\"\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "93e1d968-5ed8-4386-ac97-d7facc8029a9",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b20719b1-a4bb-4247-ae68-3b0d6ea8149e",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "openai_new",
   "language": "python",
   "name": "openai_new"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
